package com.yihaodian.cluster.admin;

import com.yihaodian.cluster.Node;
import com.yihaodian.index.meta.IndexMeta;
import com.yihaodian.index.meta.routing.RoutingTable;
import com.yihaodian.index.meta.shard.Shard;
import com.yihaodian.index.meta.shard.ShardId;
import com.yihaodian.index.meta.shard.ShardRouting;

public interface ClusterAdmin {
	
	public void setShardDataVersion(ShardId shardId, String version);

	/**
	 * set index meta.
	 * 
	 * @param meta
	 */
	public void setIndexMeta(IndexMeta meta);

	/**
	 * set routing table.
	 * 
	 * @param routingTable
	 */
	public void setRoutingTable(RoutingTable routingTable);

	/**
	 * update shard status of given node.
	 * 
	 * @param node
	 * @param shard
	 */
	public void setNodeShardStatus(Node node, ShardRouting shard);

	/**
	 * temporarily disable a shard on all the node or given node. A shard is
	 * disabled on a node, that is, although shard is assigned to the node in
	 * routing table, we do not search the node for this shard.
	 * 
	 * @param shard
	 * @param allNode
	 * @param targetNode
	 */
	public void disableShard(ShardId shard, boolean allNode, Node targetNode);

	/**
	 * enable a shard on all the node or given node.
	 * 
	 * @param shard
	 * @param allNode
	 * @param targetNode
	 */
	public void enableShard(ShardId shard, boolean allNode, Node targetNode);
	
	/**
	 * add a shard on a node,not all node, 
	 * This is based on performance considerations, because the new generation 
	 * a shard to spend a lot of resources
	 * 
	 * @param shard
	 * @param targetNode
	 */
	public void addShard(ShardId shard,Node targetNode);
	
	/**
	 * remove a shard on a node ,not all node
	 * This is based on performance considerations, since deleted a shard to spend a lot of resources
	 * @param shard
	 * @param targetNode
	 */
	
	public void removeShard(ShardId shard,Node targetNode);
}
